#!/bin/bash
echo "启动分布式缓存系统..."
docker-compose up --build -d

echo "等待服务启动..."
sleep 5

echo "测试集群健康状态..."
for port in 9527 9528 9529; do
    response=$(curl -s -w "%{http_code}" http://127.0.0.1:$port/health -o /dev/null)
    if [ $response -eq 200 ]; then
        echo "节点 127.0.0.1:$port 运行正常"
    else
        echo "节点 127.0.0.1:$port 启动失败"
    fi
done

echo ""
echo "集群已启动！"
echo "访问地址："
echo "- http://127.0.0.1:9527"
echo "- http://127.0.0.1:9528"
echo "- http://127.0.0.1:9529"
echo ""
echo "使用客户端：cd client && python client.py"
echo "停止集群：docker-compose down"
